package com.lxhdj.management.security;

import com.lxhdj.common.model.SystemUserModel;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

public class UserDetail implements UserDetails {
    private SystemUserModel userModel;

    public SystemUserModel getUserModel() {
        return userModel;
    }

    public void setUserModel(SystemUserModel userModel) {
        this.userModel = userModel;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return userModel == null ? null : userModel.getPassword();
    }

    @Override
    public String getUsername() {
        return userModel == null ? null : userModel.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return userModel == null || userModel.getAccountNonExpired();
    }

    @Override
    public boolean isAccountNonLocked() {
        return userModel == null || userModel.getAccountNonLocked();
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return userModel == null || userModel.getCredentialsNonExpired();
    }

    @Override
    public boolean isEnabled() {
        return userModel == null || userModel.getEnabled();
    }
}
